<?php
namespace Home\Widget;
use Common\Controller\HomeBaseController;
use Think\Model;
use Common\Model\ZuorenwuModel;
use Common\Model\MemberModel;
use Common\Model\ArticleModel;
use Common\Model\RenwuModel;
/**
 * Home挂件
 * @author RockSnap
 *
 */
class PageWidget extends HomeBaseController {
	
	public function menu() {
		if(MID){
			$renwu = new RenwuModel();
			$member = new MemberModel();
			//判断用户类型
			$user = session('user_auth');
			//进行中的任务总数
			$this->num = $renwu->where("status > 1 and sid = ".MID)->count();
			//可用金额
			$this->keyong = $member->where("id=".MID)->getField("able_money");
		}
		$this->display('Widget:menu');
	}
	
	public function foot() {
		$this->display('Widget:foot');
	}
	
	public function shuainfo() {
		$article = new ArticleModel();
		$member = new MemberModel();
		$renwu = new RenwuModel();
		//账户信息
		$this->info = $member->where("id=".MID)->find();
		//刷手教程文章
		$jiaocheng = $article->where("status = 1 and cate = 5")->limit(5)->select();
		$this->assign("jiaocheng",$jiaocheng);
		//已完成的人任务总数
		$this->num = $renwu->where("status = 5 and sid = ".MID)->count();
		
		$article = new ArticleModel();
		//商家公告
		$gonggao1 = $article->where("status = 1 and cate = 9")->select();
		$this->assign("gonggao1",$gonggao1);
		//会员公告
		$gonggao2 = $article->where("status = 1 and cate = 8")->select();
		$this->assign("gonggao2",$gonggao2);
		$this->display('Widget:shuainfo');
	}
	
	public function shanginfo() {
		$article = new ArticleModel();
		$member = new MemberModel();
		$renwu = new RenwuModel();
		//商家账户信息
		$this->info = $member->where("id=".MID)->find();
		//商家教程文章
		$jiaocheng = $article->where("status = 1 and cate = 5")->limit(5)->select();
		$this->assign("jiaocheng",$jiaocheng);
		//已完成的人任务总数
		$this->num = $renwu->where("status = 5 and sid = ".MID)->count();
		
		$article = new ArticleModel();
		//商家公告
		$gonggao1 = $article->where("status = 1 and cate = 9")->select();
		$this->assign("gonggao1",$gonggao1);
		//会员公告
		$gonggao2 = $article->where("status = 1 and cate = 8")->select();
		$this->assign("gonggao2",$gonggao2);
		$this->display('Widget:shanginfo');
	}
}